package com.snack.dao.impl.admin;

import com.snack.dao.admin.UserDAO;
import com.snack.db.DbHelper;
import com.snack.entity.admin.User;

public class UserDAOImpl implements UserDAO {

	@Override
	public int save(User user) {
		try {  
			return DbHelper.execute("INSERT INTO S_USER (C_NAME, C_PASSWORD) VALUE(?,?)", new Object[] { user.getName(), user.getPassword()});
		} catch (Exception e) {
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public int update(User user) {
		return DbHelper.execute("UPDATE S_USER SET C_NAME=?, C_PASSWORD=? WHERE C_ID = ?", user.getName(), user.getPassword(), user.getId());
	}

}
